$(document).ready(function() {

	$("#saveBtn").click(function() {
		// alert($("input:checkbox:checked").val());
			var parms = new Object();
			var url = "/index.php?mod=controller1";
			parms["action"] = "saveAccountDetails";
			parms["accId"] = $("#accountId").val();
			parms["openingBalance"] = $("#openingBal").val();
			parms["accNum"] = $("#accNum").val();
			parms["accName"] = $("#accName").val();

			if ($("input:checkbox:checked").val() == "active") {
				parms["accActive"] = 1;
			} else {
				parms["accActive"] = 0;
			}

			$.post(url, parms, function(resultData) {
				//alert(resultData);
				var errorCode = $(resultData).find("code").text();
				if (errorCode == 0) {
					//location.reload();
					alert("Account details saved successfully.");
					location.replace("/index.php?mod=myaccounts");
				} else {
					alert($(resultData).find("errMessage").text());
				}
			});

		});
	
	$("#cancelBtn").click(function(){
		location.replace("/index.php?mod=myaccounts");
	});

});